package com.fy.spring.cloud.controller;

import com.fy.spring.cloud.bean.MyProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class TestController {
    @Value("${user.name}")
    private String username;

    @Value("${info.version:'defaultVersion'}")
    private String version;

    @Autowired
    private MyProperties myProperties;

    @GetMapping("/nacos/username")
    public String getUsername() {
        return username + " " + version;
    }

    @GetMapping("/nacos/name/prop")
    public String getUserProp() {
        return myProperties.getName();
    }
}
